#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setWindowTitle("wangzn2016-即时通讯");
    // 初始化登录页面
    _login_dlg = new LoginDialog(this);
    setCentralWidget(_login_dlg);

    // 创建和注册消息的链接
    connect(_login_dlg, &LoginDialog::switchRegister, this, &MainWindow::SlotSwitchReg);

    // 初始化注册页面
    _register_dlg = new RegisterDialog(this);

    _login_dlg->setWindowFlags(Qt::CustomizeWindowHint|Qt::FramelessWindowHint);
    _register_dlg->setWindowFlags(Qt::CustomizeWindowHint|Qt::FramelessWindowHint);

    _register_dlg->hide();
}

MainWindow::~MainWindow()
{
    delete ui;
}

// 槽函数SlotSwitchReg
void MainWindow::SlotSwitchReg()
{
    setCentralWidget(_register_dlg);
    // hide登录页面
    _login_dlg->hide();
    // 现实注册页面
    _register_dlg->show();

}
